﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    <script charset="utf-8" src="/resources/scripts/ajaxfileupload.js"></script>
}

@using AFT.Parking.Entity
@model QualityRecord
<div class="content-box">
    <!-- Content box header -->
    <div class="content-box-header clearfix">
        <h3>添加工程质量信息</h3>
    </div>

    <!-- Content box body -->
    <div class="content-box-content">
        <div class="tab-content default-tab" id="tab2">
            <form method="post" id="frm">
                <fieldset class="fieldset-floor-left">
                    <div>
                        <label>垂平(附件)</label>
                        @{
                            var verImg = string.IsNullOrEmpty(Model.VerHorizontal) ? "/resources/images/picture-model.png" : Model.VerHorizontal;
                        }
                        <div class="upload">
                            <img style="width: 120px; height: 120px;" src="@verImg"/>
                            <input type="hidden" name="VerHorizontal" value="@Model.VerHorizontal"/>
                            <button type="button" class="button" id="VerHorizontal">上传垂平附件</button>
                        </div>
                    </div>

                    <div>
                        <label>楼板厚度(附件)</label>
                        @{
                            var thicknessImg = string.IsNullOrEmpty(Model.SlabThickness) ? "/resources/images/picture-model.png" : Model.SlabThickness;
                        }
                        <div class="upload">
                            <img style="width: 120px; height: 120px;" src="@thicknessImg"/>
                            <input type="hidden" name="SlabThickness" value="@Model.SlabThickness"/>
                            <button type="button" class="button" id="thickness">上传楼板厚度附件</button>
                        </div>
                    </div>

                    <div>
                        <label>顶板水平度(附件)</label>
                        @{
                            var roofImg = string.IsNullOrEmpty(Model.RoofLevelness) ? "/resources/images/picture-model.png" : Model.RoofLevelness;
                        }
                        <div class="upload">
                            <img style="width: 120px; height: 120px;" src="@roofImg"/>
                            <input type="hidden" name="RoofLevelness" value="@Model.RoofLevelness"/>
                            <button type="button" class="button" id="roof">上传顶板水平度附件</button>
                        </div>
                    </div>

                    <div>
                        <label>方正度(附件)</label>
                        @{
                            var squarenessImg = string.IsNullOrEmpty(Model.Squareness) ? "/resources/images/picture-model.png" : Model.Squareness;
                        }
                        <div class="upload">
                            <img style="width: 120px; height: 120px;" src="@squarenessImg"/>
                            <input type="hidden" id="ImgShow" name="Squareness" value="@Model.Squareness"/>
                            <button type="button" class="button" id="squareness">上传方正度附件</button>
                        </div>
                    </div>
                </fieldset>
                <fieldset class="fieldset-floor-right quality">
                    @Html.Hidden("Id", Model.Id)
                    @Html.Hidden("TagId", Model.TagId)
                    @Html.Hidden("CreatorId", Model.CreatorId)
                    @Html.Hidden("CreateTime", Model.CreateTime)
                    <p>
                        <label>标题</label>
                        @Html.TextBox("Name", Model.Name, new {@class = "text-input x-input"})
                    </p>

                    <div class="x-tab-item">
                        <p>
                            <label>二维码名称 (注：请保证二维码名称不一致，便于区分)</label>
                            @if (Model.Id > 0)
                            {
                                @Html.TextBox("TagName", Model.TagName, new {@class = "text-input x-input", @readonly = "readonly", style = "background: #E4E4E4;cursor:not-allowed"})
                            }
                            else
                            {
                                @Html.TextBox("TagName", Model.TagName, new {@class = "text-input x-input"})
                            }
                        </p>
                        <p>
                            <label>楼栋编号</label>
                            @Html.TextBox("BuildingNo", Model.BuildingNo, new {@class = "text-input x-input"})
                        </p>
                        <p>
                            <label>楼层编号</label>
                            @Html.TextBox("FloorNo", Model.FloorNo, new {@class = "text-input x-input"})
                        </p>
                        <p>
                            <label>
                                <span class="label-left x-contacter">栋号长</span>
                                <span class="label-left x-label-num">栋号长联系方式</span>
                            </label>
                            <input type="text" name="BuildingMnnager" value="@Model.BuildingMnnager" class="text-input x-contacter" placeholder="栋号长姓名"/>
                            <input type="text" name="BuildingManagerNum" value="@Model.BuildingManagerNum" class="text-input x-contact-num" placeholder="栋号长联系电话"/>
                        </p>
                        <p>
                            <label>
                                <span class="label-left x-contacter">质检员</span>
                                <span class="label-left x-label-num">质检员联系方式</span>
                            </label>
                            @Html.TextBox("Inspector", Model.Inspector, new {@class = "text-input x-contacter", placeholder = "质检员姓名"})
                            @Html.TextBox("InspectorNum", Model.InspectorNum, new {@class = "text-input x-contact-num", placeholder = "质检员联系方式"})
                        </p>
                        <p>
                            <label>浇注日期</label>
                            @Html.TextBox("PouringDate", Model.PouringDate, new {@class = "text-input x-input"})
                        </p>
                        <p>
                            <label>养护日期</label>
                            @Html.TextBox("MaintananceDate", Model.MaintananceDate, new {@class = "text-input x-input"})
                        </p>
                        <p>
                            <label>验收日期</label>
                            @Html.TextBox("CheckDate", Model.CheckDate, new {@class = "text-input x-input"})
                        </p>
                        <p class="x-btns">
                            <input class="button x-btn" type="submit" id="btnSubmit" value="&nbsp;保 存&nbsp;"/>
                            <input class="button x-btn" type="button" id="btnBack" value="&nbsp;返 回&nbsp;"/> <br/>
                            <span class="input-notification @ViewBag.Icon png_bg">@ViewBag.Message</span>
                            <input type="hidden" id="hd_backUrl" value="@Url.Action("List")">
                        </p>
                    </div>
                </fieldset>
            </form>
        </div>
    </div>
</div>


<script>
    new AjaxUpload($("#VerHorizontal"), {
        action: '@Url.Action("UpLoadFile")',
        data: { folderName: "QualityRecordFile"},
        name: 'UploadImg',
        responseType: "json",
        onSubmit: function (file, extension) {
        },
        onComplete: function (file, data) {
            console.log($(this).html());
            var btn = $(this._button);
            var fileImg = btn.siblings('img');
            var imgShow = btn.prev();
            console.log(fileImg, imgShow);
            if (data.Value) {
                fileImg.attr("src", data.Result[0]);
                imgShow.val(data.Result[0]);
            }
            else {
                alert("上传失败。");
            }
        }
    });
    new AjaxUpload($('#thickness'), {
        action: '@Url.Action("UpLoadFile")',
        data: { folderName: "QualityRecordFile" },
        name: 'UploadImg',
        responseType: "json",
        onSubmit: function (file, extension) {
        },
        onComplete: function (file, data) {
            console.log($(this).html());
            var btn = $(this._button);
            var fileImg = btn.siblings('img');
            var imgShow = btn.prev();
            console.log(fileImg, imgShow);
            if (data.Value) {
                fileImg.attr("src", data.Result[0]);
                imgShow.val(data.Result[0]);
            }
            else {
                alert("上传失败。");
            }
        }
    });
    new AjaxUpload($('#roof'), {
        action: '@Url.Action("UpLoadFile")',
        data: { folderName: "QualityRecordFile" },
        name: 'UploadImg',
        responseType: "json",
        onSubmit: function (file, extension) {
        },
        onComplete: function (file, data) {
            console.log($(this).html());
            var btn = $(this._button);
            var fileImg = btn.siblings('img');
            var imgShow = btn.prev();
            console.log(fileImg, imgShow);
            if (data.Value) {
                fileImg.attr("src", data.Result[0]);
                imgShow.val(data.Result[0]);
            }
            else {
                alert("上传失败。");
            }
        }
    });
    new AjaxUpload($('#squareness'), {
        action: '@Url.Action("UpLoadFile")',
        data: { folderName: "QualityRecordFile" },
        name: 'UploadImg',
        responseType: "json",
        onSubmit: function (file, extension) {
        },
        onComplete: function (file, data) {
            console.log($(this).html());
            var btn = $(this._button);
            var fileImg = btn.siblings('img');
            var imgShow = btn.prev();
            console.log(fileImg, imgShow);
            if (data.Value) {
                fileImg.attr("src", data.Result[0]);
                imgShow.val(data.Result[0]);
            }
            else {
                alert("上传失败。");
            }
        }
    });
</script>

<script type="text/javascript">
    $(function () {
        laydate({
            elem: '#PouringDate'
        });
        laydate({
            elem: '#MaintananceDate'
        });
        laydate({
            elem: '#CheckDate'
        });
    });
</script>
